home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
comm1
/
intsdkss.lha
/
unix.doc
< prev
Wrap
Text File
|
1996-04-09
|
37KB
|
1,748 lines
TABLE OF CONTENTS
unix/access
unix/chdir
unix/chmod
unix/clean_sock
unix/close
unix/closedir
unix/daemon_end
unix/daemon_start
unix/dup
unix/dup2
unix/err
unix/errx
unix/exit
unix/getcwd
unix/getopt
unix/getwd
unix/glob
unix/globfree
unix/init_sock
unix/isatty
unix/mkdir
unix/opendir
unix/pclose
unix/perror
unix/popen
unix/read
unix/readdir
unix/rewinddir
unix/rmdir
unix/sleep
unix/SockBase
unix/socket_callback
unix/stat
unix/statfs
unix/s_accept
unix/s_socket
unix/verr
unix/verrx
unix/vwarn
unix/vwarnx
unix/warn
unix/warnx
unix/write
unix/access unix/access
NAME
access -- Check the accessibility of a file
SYNOPSIS
return = access (filename, mode)
int access (const char *, int);
FUNCTION
Checks to see if a file can be accessed with a certain mode.
Returns true (0) if mode is write and file is not found.
INPUTS
filename name of the file
mode file mode
If filename is ".", then it is dealt with as being the
current directory (i.e., a "" is passed to Lock()). If
filename is "..", then it is dealt with as being the
parent directory (i.e., a "/" is passed to Lock()). No
other "Unix-like" translation is performed.
Mode table
Integer Mnemonic Description
0 F_OK Does file exist?
1 X_OK Is it executable?
2 W_OK Is it writable?
4 R_OK Is it readable?
Mnemonics are in <sys/fcntl.h>.
RESULT
0 is returned if successful.
-1 is returned on error, and errno is set appropriately.
EXAMPLE
NOTES
If the file doesn't exist, access() assumes that the file
can be written.
BUGS
Executable and readable are treated the same on the Amiga.
SEE ALSO
unix/chdir unix/chdir
NAME
chdir -- change directory
SYNOPSIS
result = chdir (path)
int chdir (const char *);
FUNCTION
chdir() changes the current working directory to the
specified path.
chdir() ensures that the original starting directory
is returned to upon program exit.
INPUTS
path directory/pathname to change to
RESULT
On success, 0 is returned.
On failure, -1 is returned, and errno is set.
EXAMPLE
NOTES
BUGS
SEE ALSO
unix/chmod unix/chmod
NAME
chmod -- change directory
SYNOPSIS
return = chmod (name, unixmask)
int chmod (const char *name, const int unixmask);
FUNCTION
chmod() changes the specified file's attributes. It
translates the UNIX compatible attribute mask into the
equivalent Amiga attributes, then sets those protections
on the given file.
chmod() will set the GROUP and OTHER attributes, as
well as the standard set of -SPARWED, though no current
Amiga OS (<= V42) will copy or pay any attention to
these, it is still useful for NFS mounted volumes.
INPUTS
name - name of file to modify
unixmask - UNIX attribute mask for a file
RESULT
0 is returned if successful. -1 is returned on error.
EXAMPLE
NOTES
BUGS
SEE ALSO
chmod command (in Inet:c, docs in Inet:docs/chmod.guide)
unix/clean_sock unix/clean_sock
NAME
clean_sock - cleanup and shutdown socket.library
SYNOPSIS
clean_sock ();
void clean_sock (void);
FUNCTION
clean_sock() determines whether socket.library is
open, and if so, calls cleanup_sockets(), closes
the library, and sets the library base to NULL.
The internal (to unix.lib) indicator for socket
being setup is reset.
INPUTS
None.
RESULT
None.
NOTES
For clients, and non-inetd servers, this should be called
from an auto-termination routine, after standard I/O cleanup
is complete. The suggested name and priority for the destructor
is _STD_175_cleanup.
For inetd servers, this should be called prior to standard I/O
cleanup, but still in an auto-termination routine.
BUGS
SEE ALSO
init_sock()
unix/close unix/close
NAME
close -- close a file or socket
SYNOPSIS
status = close (unit);
int = close (int);
FUNCTION
This function closes a file or socket.
INPUTS
unit unit number
RESULT
status = 0 if successful
= -1 if error occurred
EXAMPLE
NOTES
This replaces the normal compiler close() function.
close() is a wrapper for the __close() function in
sc.lib and for s_close() in socket.library. If the unit
has been marked as a socket, then s_close() is called,
otherwise __close() is called.
If you are using unix.lib to obtain stdio on sockets,
you must use close() instead of __close(). You must
also open socket.library using init_sock().
BUGS
SEE ALSO
init_sock
read
write
unix/closedir unix/closedir
NAME
closedir -- closes a directory stream
SYNOPSIS
#include <sys/dir.h>
result = closedir (dirp)
int closedir (DIR *);
FUNCTION
Closes the named directory stream.
INPUTS
dirp directory stream from opendir().
RESULT
Returns 0.
EXAMPLE
NOTES
It is safe to call closedir() with a NULL parameter.
You should not touch the parameter after calling
closedir() as its memory will be freed.
BUGS
SEE ALSO
readdir(), rewinddir(), opendir()
unix/daemon_end unix/daemon_end
NAME
daemon_end - reverse daemon_start effects
SYNOPSIS
void daemon_end (void);
FUNCTION
This function restores the compiler provided stdin and
stdout to where compiler clean-up code expects it.
INPUTS
None.
RESULT
None.
NOTES
This is normally called from a destructor (_STD) routine.
clean_sock() should be called after daemon_end().
BUGS
SEE ALSO
daemon_start
clean_sock
unix/daemon_start unix/daemon_start
NAME
daemon_start - map stdout and stdin to inetd socket
SYNOPSIS
int daemon_start (unsigned long *sp)
FUNCTION
daemon_start() goes through a variety of machinations
to close down the compiler provided stdin and stdout,
and then inherit the socket provided by inetd, and then
map that socket to stdin, then duplicate the socket and
map the duplicate to stdout.
INPUTS
'sp' is the value of the second parameter (SOCKPTR)
provided by inetd.
RESULT
On success, 0 is returned.
On failure, -1 is returned, and errno is set.
NOTES
init_sock() should be called prior to calling daemon_start().
This is typically called from a constructor (_STI) routine.
BUGS
SEE ALSO
init_sock
s_inherit()
daemon_end
unix/dup unix/dup
NAME
dup - duplicate an open file descriptor
SYNOPSIS
int dup (int oldfd);
FUNCTION
Essentially a front-end to dup2(), dup() finds the
first free file descriptor, and then calls dup2()
with that as the "newfd" parameter.
INPUTS
The file descriptor to be duplicated.
RESULT
On success, the new fd.
On failure, -1, and errno is set.
NOTES
Works for sockets and file descriptors. See dup2()
for caveats.
dup() does some sanity checking before calling dup2().
BUGS
See dup2().
SEE ALSO
dup2()
unix/dup2 unix/dup2
NAME
dup2 - duplicate an open file descriptor
SYNOPSIS
int dup2 (int oldfd, int newfd);
FUNCTION
"oldfd" is a file descriptor referring to an open file,
and "newfd" is a non-negative integer. dup2() causes
"newfd" to refer to the same file as "oldfd".
This implementation works for sockets, as well as for
files.
If "newfd" refers to a current open file or socket, it is
close()'d.
If "oldfd" is not open, an error is returned. If "oldfd"
or "newfd" are less than zero, an error is returned. If
a new file descriptor cannot be allocated for "newfd",
an error is returned.
INPUTS
See above.
RESULT
On success, "newfd" is returned.
On failure, -1 is returned, and errno is set.
NOTES
If you are using unix.lib to obtain stdio on sockets, you
must use dup() and dup2() from unix.lib, and not s_dup() and
s_dup2() from socket.library.
For sockets, this implementation is faithful to the Unix
implementation. For _files_, a close() on "newfd" is _ignored_.
For close action to take place, the _original_ fd must be
close. If the original is closed, and the duplicate is not,
operations on the duplicate are undefined (and a crash is
likely).
A tiny bit of trickery can turn these around. If you want the
duplicate to be the "master" then:
if (ufb = __chkufb (newfd))
ufb->ufbflg &= ~UFB_NC;
if (ufb = __chkufb (oldfd))
ufb->ufbflg |= UFB_NC;
BUGS
The SAS/C file abstraction is not "abstract enough" to make this
completely right on the Amiga (for files, sockets are fine).
SEE ALSO
unix/err unix/err
NAME
err -- print an error message and EXIT.
SYNOPSIS
#include <err.h>
err (eval, fmt, ...)
void err (int eval, const char *fmt, ...);
FUNCTION
Prints an error message of the form
<progname>: [<formatted fmt>: ]<errno error message>
and then exits with the value of 'eval'.
INPUTS
eval - value for exit() call; program return code
fmt - if non-NULL, format & print output, followed
by errno information string. If NULL, only
errno information string is output.
... - variable list of args for format string, fmt
RESULT
None
EXAMPLE
NOTES
First appeared in BSD 4.4.
BUGS
SEE ALSO
verr(), errx(), verrx(), warn(), vwarn(), warnx(), vwarnx()
unix/errx unix/errx
NAME
errx -- print an error message and EXIT.
SYNOPSIS
#include <err.h>
errx (eval, fmt, ...)
void errx (int eval, const char *fmt, ...);
FUNCTION
Prints an error message of the form
<progname>: [<formatted fmt>]
and then exits with the value of 'eval'.
INPUTS
eval - value for exit() call; program return code
fmt - if non-NULL, format & print output
... - variable list of args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), verr(), verrx(), warn(), vwarn(), warnx(), vwarnx()
unix/exit unix/exit
NAME
exit -- cleanup and exit program
SYNOPSIS
exit (status)
void exit (int);
FUNCTION
This routine closes all stdio (level 2) files.
The BSD return code is mapped to an AmigaDOS return code.
INPUTS
status integer - mapped as follows
BSD AmigaDOS
1 RETURN_FAIL (20)
0 RETURN_OK (0)
-1 RETURN_WARN (5)
NOTES
BUGS
Doesn't call atexit() routines. Use autoexit destructors
instead.
SEE ALSO
unix/getcwd unix/getcwd
NAME
getcwd -- get the Current Working Directory.
SYNOPSIS
p = getcwd (b, size);
char *getcwd (char *b, int size);
FUNCTION
This function obtains the path name for the current working
directory. If the buffer pointer b is not NULL, then the path
string is placed there if it will fit, and the return pointer p
is the same as the pointer b. If the pointer b is NULL, then the
malloc() function is used to obtain a buffer of size bytes to
hold the path string. In the latter case, you should use the
free() function to release the buffer when you are finished with
it.
INPUTS
b - Points to path buffer
size - Size of path buffer
RESULT
p - Same as b if successful, else NULL and errno
contains error information.
EXAMPLE
NOTES
BUGS
SEE ALSO
getwd()
unix/getopt unix/getopt
NAME
getopt - get option letter from argument vector
SYNOPSIS
int getopt (int argv, char **argv, char *optstring);
extern char *optarg;
extern int optind, opterr, optopt;
FUNCTION
getopt() returns the next options letter in "argv" that
matches a letter in "optstring".
"optstring" must contain the valid option letters. If a
if a letter is followed by a colon, the option is required
to have an argument (which may be separated from the letter
by white space). "optarg" points to the argument when
getopt() returns.
"optind" is the index into "argv" of the next argument to
be processed. It is external to the calling program, and
is initialized to one prior to the first getopt() call.
When all options have been processed, getopt() returns
EOF.
INPUTS
RESULT
EOF when done.
'?' when an unknown option letter is encountered.
Otherwise, the letter to be processed.
NOTES
If an error occurs, getopt() prints an error message on
stderr. This can be suppresed by setting opterr to zero.
The value of the character that caused the error is
contained in optopt.
The special string "--" causes getopt() to return EOF.
BUGS
SEE ALSO
unix/getwd unix/getwd
NAME
getwd -- get the Current Working Directory.
SYNOPSIS
p = getwd (b);
char *getwd (char *b);
FUNCTION
This function obtains the path name for the current working
directory. If the buffer pointer b is not NULL, then the path
string is placed there if it will fit, and the return pointer p
is the same as the pointer b. If the pointer b is NULL, then the
malloc() function is used to obtain a buffer of MAXPATHLEN bytes
to hold the path string. In the latter case, you should use the
free() function to release the buffer when you are finished with
it.
INPUTS
b - Points to path buffer. Assumed to be of size
MAXPATHLEN or greater.
RESULT
p - Same as b if successful, else NULL
EXAMPLE
NOTES
You should use getcwd() instead, so that the buffer size may be
specified.
BUGS
SEE ALSO
getcwd()
unix/glob unix/glob
NAME
glob - find pathnames matching a pattern
SYNOPSIS
#include <glob.h>
int glob (const char *pattern, int flags,
int errfunc (char char *epath, int eerrno),
glob_t *pglob);
FUNCTION
The glob() function searches for all the pathnames
matching "pattern" according the rules used by the
Unix shell. No tilde expansion or parameter substitution
is done.
The results of a glob() call are stored in the structure
pointed to by pglob, which is a glob_t which is declared
in <glob.h> as
typedef struct
{
int gl_pathc; /* Count of paths matched so far */
char **gl_pathv; /* List of matched pathnames. */
int gl_offs; /* Slots to be reserved in `gl_pathv'. */
int gl_flags; /* Flags for globbing */
} glob_t;
Results are stored in dynamically allocated storage.
The parameter flags is made up of bitwise OR of zero or
more of the following symbolic constants, which modify the
of behaviour of glob():
GLOB_ERR
which means to return upon read error (because a
directory does not have read permission, for exam-
ple).
GLOB_MARK
which means to append a slash to each path which
corresponds to a directory,
GLOB_NOSORT
which means don't sort the returned pathnames (they
are by default),
GLOB_DOOFS
which means that pglob->gl_offs slots will be
reserved at the beginning of the list of strings in
pglob->pathv,
GLOB_NOCHECK
which means that, if no pattern matches, to return
the original pattern,
GLOB_APPEND
which means to append to the results of a previous
call. Do not set this flag on the first invocation
of glob().
GLOB_NOESCAPE
which means that meta characters cannot be quoted
by backspaces, and
GLOB_PERIOD
which means that a leading period can be matched by
meta characters.
If errfunc is not NULL, it will be called in case of an
error with the arguments epath a pointer to the path which
failed and eerrno the value of errno as returned from one
of the calls to opendir(), readdir(), or stat(). If
errfunc returns non - zero, or if GLOB_ERR is set, glob()
will terminate after the call to errfunc.
Upon successful return, mpglob->gl_pathc contains the number
of matched pathnames and pglob->gl pathv a pointer to the
list of matched pathnames. The first pointer after the last
pathname is NULL.
It is possible to call glob() several times. In that case,
the GLOB_APPEND flag has to be set in flags on the second
and later invocations.
INPUTS
RESULT
On successful completion, glob() returns zero. Other possible
returns are:
GLOB_NOSPACE
for running out of memory,
GLOB_ABEND
for a read error, and
GLOB_NOMATCH
for no found matches.
NOTES
BUGS
The glob() function may fail due to failure of underlying
function calls, such as malloc() or opendir(). These will
store their error code in errno.
SEE ALSO
unix/globfree unix/globfree
NAME
globfree - free memory from glob()
SYNOPSIS
#include <glob.h>
void globfree (glob_t *pglob);
FUNCTION
The globfree() function frees the dynamically allocated
storage from an earlier call to glob().
INPUTS
A glob_t passed earlier to glob().
RESULT
None.
NOTES
BUGS
SEE ALSO
unix/init_sock unix/init_sock
NAME
init_sock - setup socket.library and associated stuff
SYNOPSIS
retval = init_sock ();
D0
int init_sock (void);
FUNCTION
init_sock() determines whether socket.library has already
been opened and setup previously. If so, it does nothing
and returns with a value of zero.
Otherwise, init_sock() opens the library, calls setup_sockets()
with FD_SETSIZE (i.e., the maximum number of sockets allowed)
and the default "extern int errno".
The socket allocator is pointed to the proper socket_callback()
for the compiler.
The global signals socket_sigurg and socket_sigio are set to
their default values.
The internal (to unix.lib) list of sockets is emptied.
INPUTS
None.
RESULT
0 on success
-1 on failure (errno is set to ECONFIGPROBLEM)
NOTES
For clients, this should be called from an auto-initialization
routine, before standard I/O setup. The suggested name and priority
for the constructor is _STI_175_init. For inetd servers (which map
stdin and stdout to the socket passed to them from inetd) this
should be called after standard I/O setup. For non-inetd servers,
the client recommendation applies.
BUGS
SEE ALSO
clean_sock()
setup_sockets()
s_dev_func()
s_getsignal()
unix/isatty unix/isatty
NAME
isatty - does file descriptor refer to a terminal device
SYNOPSIS
rslt = isatty (fd);
int isatty (int fd);
FUNCTION
If 'fd' refers to an interactive file descriptor, the
isatty() function returns 1, and otherwise zero.
INPUTS
fd - the file descriptor in question
RESULT
If interactive, returns 1.
If non-interactive, returns 0;
NOTES
BUGS
SEE ALSO
unix/mkdir unix/mkdir
NAME
mkdir -- make a new directory
SYNOPSIS
mkdir (path, mode)
int mkdir (const char *path, int mode);
FUNCTION
Simply calls AmigaDOS 'CreateDir()' function to create a new,
directory, then calls 'chmod()' to set the specified 'mode', or
protections, on that directory.
INPUTS
path - what directory to create
mode - mode to set for directory
RESULT
On success, 0 is returned.
On failure, -1 is returned and errno is set.
EXAMPLE
NOTES
BUGS
SEE ALSO
dos.library/CreateDir(), unix/chmod()
unix/opendir unix/opendir
NAME
opendir -- opens a directory
SYNOPSIS
#include <sys/dir.h>
dirp = opendir (dirname)
DIR *opendir (char *);
FUNCTION
Opens the named directory and returns a pointer to the
directory stream.
INPUTS
dirname name of the directory to open
RESULT
Returns a pointer to the directory stream if successful.
Returns NULL if dirname cannot be accessed, or other
error occurs.
errno is set to ENOENT, if the AmigaDOS Lock() fails, to
EIO if the AmigaDOS Examine() fails, and ENOMEM if the
allocation of the DIR structure fails.
EXAMPLE
NOTES
BUGS
SEE ALSO
readdir(), rewinddir(), closedir()
unix/pclose unix/pclose
NAME
pclose - close a pipe to another process
SYNOPSIS
#include <stdio.h>
pclose (stream);
void pclose (FILE *stream);
FUNCTION
pclose() closes a pipe opened by popen().
INPUTS
stream - the result from popen().
RESULT
None.
NOTES
BUGS
SEE ALSO
unix/perror unix/perror
NAME
perror - print a system error message
SYNOPSIS
#include <stdio.h>
void perror (const char *str);
FUNCTION
perror outputs a message to stderr (using stdio)
describing the last error encountered during a call
to a system or library function. This value is taken
from the global integer "errno".
The argument string "str" is printed first, if it is
non-NULL, then a colon and a blank, then the error
message followed by a newline.
INPUTS
str - a header string (which should include a program
name and other useful information)
RESULT
None.
NOTES
This perror() differs from the one in the compiler
library because it uses the socket.library strerror()
entrypoint to determine the error message (which
includes the standard error messages, as well as
network related ones).
Thus, if socket.library is not open, an error message
cannot be provided.
BUGS
SEE ALSO
unix/popen unix/popen
NAME
popen - initiate a pipe to another process
SYNOPSIS
#include <stdio.h>
f = popen ("ls", "r");
FILE *popen (char *program, char *type);
FUNCTION
popen() creates a pipe between the calling program and the
command to be executed. The arguments to popen() are pointers
to null terminated strings.
INPUTS
command - A Shell command line
type - I/O mode, "r" for reading, "w" for writing.
RESULT
On success, a stream pointer to the called process.
On failure, NULL.
NOTES
This depends on the PIPE: device, and that PIPE: is set
up as documented in the INet installation notes.
BUGS
SEE ALSO
unix/read unix/read
NAME
read -- read from a file or socket
SYNOPSIS
status = read (unit, buffer, length);
int = read (int, void *, unsigned int);
FUNCTION
This function reads the next set of bytes from a file
or socket that has been activated via a previous open(),
s_accept(), s_socket(), dup() or dup2() call.
INPUTS
unit unit number
buffer input buffer
length buffer length in bytes
RESULT
status = number of bytes actually read
= 0 if end of file
= -1 if error occurred
EXAMPLE
NOTES
This replaces the normal compiler read() function.
read() is a wrapper for the __read() function in
sc.lib and for recv() in socket.library. If the unit
has been marked as a socket, then recv() is called,
otherwise __read() is called.
If you are using unix.lib to obtain stdio on sockets,
you must use read() instead of __read(). You must
also open socket.library using init_sock().
BUGS
SEE ALSO
init_sock()
close()
write()
unix/readdir unix/readdir
NAME
readdir -- reads a directory
SYNOPSIS
#include <sys/dir.h>
next_dir = readdir (dirp)
struct direct *readdir (DIR *);
FUNCTION
returns a pointer to the next directory entry.
INPUTS
dirp directory stream from opendir().
RESULT
Returns a pointer to the next directory entry if successful.
Returns NULL on end of directory.
EXAMPLE
NOTES
BUGS
SEE ALSO
opendir(), rewinddir(), closedir()
unix/rewinddir unix/rewinddir
NAME
rewinddir -- set position in directory back to beginning.
SYNOPSIS
#include <sys/dir.h>
result = rewinddir (dirp)
int rewinddir (DIR *);
FUNCTION
Sets the position in the directory stream back to the beginning.
INPUTS
dirp directory stream from opendir().
RESULT
On success, 0 is returned.
On failure, -1 is returned (errno is not set).
EXAMPLE
NOTES
BUGS
SEE ALSO
readdir(), opendir(), closedir()
unix/rmdir unix/rmdir
NAME
rmdir -- remove a directory
SYNOPSIS
rslt = rmdir (path)
int rmdir (const char *path);
FUNCTION
Simply calls AmigaDOS 'DeleteFile()' function (since there is no
real distinction in the Amiga OS between files and directories,
at least as far as deleting them goes) on the given path.
INPUTS
path - path to directory to remove
RESULT
On success, 0 is returned.
On failure, -1 is returned, and errno is set.
EXAMPLE
NOTES
BUGS
SEE ALSO
dos.library/DeleteFile()
unix/sleep unix/sleep
NAME
sleep -- suspend execution for specified seconds
SYNOPSIS
sleep (seconds)
void sleep (int seconds);
FUNCTION
Simplistic function. Simply calls AmigaDOS 'Delay()' function
with 'seconds * TICK_PER_SECOND' as a parameter.
INPUTS
seconds - number of seconds to pause
RESULT
None
EXAMPLE
NOTES
Unix implementation returns "unsigned". Oh, well.
BUGS
SEE ALSO
dos.library/Delay()
unix/SockBase unix/SockBase
NAME
SockBase - declaration of library base for socket.library
SYNOPSIS
extern struct Library *SockBase;
FUNCTION
Simply a declaration of the library base for socket, used
if not declared in other code.
INPUTS
RESULT
NOTES
BUGS
SEE ALSO
unix/socket_callback unix/socket_callback
NAME
socket_callback - can 'fd' by used by socket.library
SYNOPSIS
retval = socket_callback (fd)
D0 D0
SAS/C:
unsigned long __regargs __asm __saveds socket_callback (register __d0 int fd
);
DICE:
unsigned long __geta4 socket_callback (__d0 int fd);
FUNCTION
socket_callback() checks, for a given compiler, whether a
given 'fd' is already in use by the program.
INPUTS
'fd' is the file descriptor to be checked.
RESULT
If the fd is invalid, -1 is returned.
If the fd is in use, 1 is returned.
If the fd is available for use, 0 is returned.
NOTES
Invalid means "< 0".
For the SAS/C library, socket_callback() uses
__chkufb() and checks the ufb->ufbflg if it's
result is non-NULL.
For the DICE library, socket_callback() uses
__getfh() and makes sure the result is NULL.
Take care that all fd and sockets are marked
correctly.
BUGS
SEE ALSO
s_dev_func
unix/stat unix/stat
NAME
stat, fstat -- get file status
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
return = stat (filename, buf)
return = fstat (fd, buf)
return = lstat (filename, buf)
int stat (const char *, struct stat *);
int fstat (int, struct stat *);
int lstat (const char *, struct stat *);
FUNCTION
stat() obtains information about the named file. fstat()
obtains information about the specified file descriptor.
lstat() functions exactly as does stat(), it does not
return data only upon the link.
The stat structure pointer to by "buf" is filled in. The
following fields are used:
u_short st_mode;
short st_uid;
short st_gid;
long st_size;
long st_mtime;
long st_atime; same as st_mtime
short st_nlink; always 1
long st_blksize;
long st_blocks;
INPUTS
filename full or relative pathname of file
fd file descriptor
buf pointer to a stat structure
RESULT
On success, 0 is returned.
On failure, -1 is returned, and errno is set.
EXAMPLE
struct stat buf;
if (stat ("devs:foo", &buf) == -1)
{
printf ("Error: file not found\n");
exit (1);
}
NOTES
On Amiga files, st_uid and st_gid will be set to that
of the local user. The networking software must have been
started or -1 will be returned for both.
While I-Net 225 in general does require 2.04 and above,
these routines specfically do.
BUGS
SEE ALSO
unix/statfs unix/statfs
NAME
statfs, fstatfs -- get file system status
SYNOPSIS
#include <sys/vfs.h>
return = statfs (filename, buf)
return = fstatfs (fd, buf)
int statfs (const char *, struct statfs *);
int fstatfs (int, struct statfs *);
FUNCTION
stat() obtains information about the named filesystem.
fstatfs() obtains information about the filesystem that
the specified file descriptor resides upon.
The statfs structure pointer to by "buf" is filled in. The
following fields are used:
struct statfs {
long f_type; /* type of filesystem */
long f_bsize; /* optimal transfer block size */
long f_blocks; /* total data blocks in file system */
long f_bfree; /* free blocks in fs */
long f_bavail; /* free blocks avail to non-superuser */
long f_files; /* total file nodes in file system */
long f_ffree; /* free file nodes in fs */
fsid_t f_fsid; /* file system id */
long f_namelen; /* maximum length of filenames */
#define f_namemax f_namelen
char f_basetype [32];
long f_flag;
};
INPUTS
filename full or relative pathname of file
fd file descriptor
buf pointer to a statfs structure
RESULT
On success, 0 is returned.
On failure, -1 is returned, and errno is set.
EXAMPLE
struct statfs buf;
if (statfs ("devs:foo", &buf) == -1)
{
printf ("Error: file not found\n");
exit (1);
}
NOTES
Most information for this command comes from the Info()
dos.library call. f_fsid[0] is the DOS UnitNumber. f_fsid[1]
is always zero. f_basetype is either OFS, FFS, IOFS, IFFS,
or the id_DiskType if the above are not appropriate.
f_namelen is always 107, but the filesystem may not be able
to support a name that long!
BUGS
SEE ALSO
unix/s_accept unix/s_accept
NAME
s_accept - accept socket and mark it as used
SYNOPSIS
retval = s_accept (sock, name, lenp)
int s_accept (int, struct sockaddr *, int *);
FUNCTION
s_accept() is a wrapper for the accept() function in
socket.library. It marks the socket returned as in-use
for the compiler, so that the compiler will not open
a file with the same descriptor number.
If you are using unix.lib to obtain stdio on sockets,
you must use s_accept() instead of accept(). You must
also open socket.library using init_sock().
INPUTS
Same as accept()
RESULT
Same as accept()
NOTES
BUGS
SEE ALSO
accept()
s_socket()
unix/s_socket unix/s_socket
NAME
s_socket - obtain socket and mark it as used
SYNOPSIS
retval = s_socket (addr_fam, type, prot_fam);
int s_socket (int, int, int);
FUNCTION
s_socket() is a wrapper for the socket() function in
socket.library. It marks the socket returned as in-use
for the compiler, so that the compiler will not open
a file with the same descriptor number.
If you are using unix.lib to obtain stdio on sockets,
you must use s_socket() instead of socket(). You must
also open socket.library using init_sock().
INPUTS
Same as socket().
RESULT
Same as socket().
NOTES
BUGS
SEE ALSO
socket()
s_accept()
unix/verr unix/verr
NAME
verr -- vectored print an error message and EXIT.
SYNOPSIS
#include <err.h>
verr (eval, fmt, args)
void verr (int eval, const char *fmt, va_list args);
FUNCTION
Prints an error message of the form
<progname>: [<formatted fmt>: ]<errno error message>
and then exits with the value of 'eval'.
INPUTS
eval - value for exit() call; program return code
fmt - if non-NULL, format & print output, followed
by errno information string. If NULL, only
errno information string is output.
args - args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), errx(), verrx(), warn(), vwarn(), warnx(), vwarnx()
unix/verrx unix/verrx
NAME
verrx -- vectored print an error message and EXIT.
SYNOPSIS
#include <err.h>
verrx (eval, fmt, args)
void verrx (int eval, const char *fmt, va_list args);
FUNCTION
Prints an error message of the form
<progname>: [<formatted fmt>]
and then exits with the value of 'eval'.
INPUTS
eval - value for exit() call; program return code
fmt - if non-NULL, format & print output
args - args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), verr(), errx(), warn(), vwarn(), warnx(), vwarnx()
unix/vwarn unix/vwarn
NAME
vwarn -- print a warning message.
SYNOPSIS
#include <err.h>
vwarn (fmt, args)
void vwarn (const char *fmt, va_list args);
FUNCTION
Prints a warning message of the form
<progname>: [<formatted fmt>: ]<errno error message>
INPUTS
fmt - if non-NULL, format & print output, followed
by errno information string. If NULL, only
errno information string is output.
args - args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), verr(), errx(), verrx(), warn(), warnx(), vwarnx()
unix/vwarnx unix/vwarnx
NAME
vwarnx -- print a warning message.
SYNOPSIS
#include <err.h>
vwarnx (fmt, args)
void vwarnx (const char *fmt, va_list args);
FUNCTION
Prints a warning message of the form
<progname>: [<formatted fmt>]
INPUTS
fmt - if non-NULL, format & print output
args - args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), verr(), errx(), verrx(), warn(), vwarn(), warnx()
unix/warn unix/warn
NAME
warn -- print a warning message.
SYNOPSIS
#include <err.h>
warn (fmt, ...)
void warn (const char *fmt, ...);
FUNCTION
Prints a warning message of the form
<progname>: [<formatted fmt>: ]<errno error message>
INPUTS
fmt - if non-NULL, format & print output, followed
by errno information string. If NULL, only
errno information string is output.
... - variable list of args for format string, fmt
RESULT
None
EXAMPLE
NOTES
First appeared in BSD 4.4.
BUGS
SEE ALSO
err(), verr(), errx(), verrx(), warnx(), vwarn(), vwarnx()
unix/warnx unix/warnx
NAME
warnx -- print a warning message.
SYNOPSIS
#include <err.h>
warnx (fmt, ...)
void warnx (const char *fmt, ...);
FUNCTION
Prints a warning message of the form
<progname>: [<formatted fmt>]
INPUTS
fmt - if non-NULL, format & print output
... - variable list of args for format string, fmt
RESULT
None
EXAMPLE
NOTES
BUGS
SEE ALSO
err(), verr(), errx(), verrx(), warn(), vwarn(), vwarnx()
unix/write unix/write
NAME
write -- write to a file or socket
SYNOPSIS
status = write (unit, buffer, length);
int = write (int, void *, unsigned int);
FUNCTION
This function writes a set of bytes to the current file
position.
INPUTS
unit unit number
buffer output buffer
length buffer length in bytes
RESULT
status = number of bytes actually written
= -1 if error occurred
EXAMPLE
NOTES
This replaces the normal compiler write() function.
write() is a wrapper for the __write() function in
sc.lib and for send() in socket.library. If the unit
has been marked as a socket, then send() is called,
otherwise __write() is called.
If you are using unix.lib to obtain stdio on sockets,
you must use write() instead of __write(). You must
also open socket.library using init_sock().
BUGS
SEE ALSO
init_socket
close
read